package gun0912.tedbottompicker.util;

import android.app.Activity;
import android.net.Uri;

import com.yalantis.ucrop.UCrop;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

/**
 * UCropUtils
 * Created by Yancy on 2016/11/2.
 */
public class UCropUtils {
    private static final int MAX_SIZE = 2400;


    public static void start(Fragment fragment, Uri source, @NonNull Uri destination, int statusBarColor, int  widgetColor, int ratio) {
        UCrop uCrop = UCrop.of(source, destination)
                .withAspectRatio(16, 9)
                .withMaxResultSize(2400, 2400);
        UCrop.Options options = new UCrop.Options();
        options.setToolbarColor(statusBarColor);
        options.setStatusBarColor(statusBarColor);
        options.setToolbarWidgetColor(widgetColor);
        options.setActiveWidgetColor(widgetColor);
        uCrop.withOptions(options);
        uCrop.start(fragment.getActivity(),fragment);
    }

    public static void start(Fragment fragment, Uri source, @NonNull Uri destination, int statusBarColor, int  widgetColor) {
        UCrop uCrop = UCrop.of(source, destination)
                .withAspectRatio(1, 1)
                .withMaxResultSize(MAX_SIZE, MAX_SIZE);

        UCrop.Options options = new UCrop.Options();
        options.setToolbarColor(statusBarColor);
        options.setStatusBarColor(statusBarColor);
        options.setToolbarWidgetColor(widgetColor);
        options.setActiveWidgetColor(statusBarColor);
        uCrop.withOptions(options);

        uCrop.start(fragment.getActivity(),fragment);

    }

    public static void start(Activity activity, Uri source, @NonNull Uri destination, int statusBarColor, int  widgetColor) {
        UCrop uCrop = UCrop.of(source, destination)
                .withAspectRatio(1, 1)
                .withMaxResultSize(MAX_SIZE, MAX_SIZE);

        UCrop.Options options = new UCrop.Options();
        options.setToolbarColor(statusBarColor);
        options.setStatusBarColor(statusBarColor);
        options.setToolbarWidgetColor(widgetColor);
        options.setActiveWidgetColor(widgetColor);
        uCrop.withOptions(options);
        uCrop.start(activity);
    }

}
/*
 *   ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 *     ┃　　　┃
 *     ┃　　　┃
 *     ┃　　　┗━━━┓
 *     ┃　　　　　　　┣┓
 *     ┃　　　　　　　┏┛
 *     ┗┓┓┏━┳┓┏┛
 *       ┃┫┫　┃┫┫
 *       ┗┻┛　┗┻┛
 *        神兽保佑
 *        代码无BUG!
 */